home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / dsniff / decode_mmxp.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-18  |  1.7 KB  |  86 lines

  1. /*
  2.   decode_mmxp.c
  3.  
  4.   Meeting Maker.
  5.  
  6.   Thanks for Matt Power <mhpower@MIT.EDU> for his BUGTRAQ post
  7.   on Meeting Maker encryption, and for providing me with traffic traces.
  8.  
  9.   The encryption algorithm seems to be much simpler than what Matt
  10.   reversed - see below...
  11.   
  12.   Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  13.   
  14.   $Id: decode_mmxp.c,v 1.3 2000/05/18 05:30:59 dugsong Exp $
  15. */
  16.  
  17. #include <sys/types.h>
  18. #include <arpa/nameser.h>
  19. #include <stdio.h>
  20. #include <string.h>
  21. #include "decode.h"
  22.  
  23. #define MM_SECRET    "Thisisastupidwasteoftimeandspace"
  24.  
  25. #define NEED(len)    { if (end - p < len) return (0); }
  26.  
  27. int
  28. decode_mmxp(u_char *buf, int len)
  29. {
  30.     static u_char *mm_xor = MM_SECRET;
  31.     u_char *p, *end;
  32.     u_long i;
  33.     int n, encrypt;
  34.  
  35.     end = buf + len;
  36.  
  37.     Buf[0] = '\0';
  38.     
  39.     if ((p = bufbuf(buf, len, "\x00\x00\x24\x55", 4)) == NULL)
  40.         return (0);
  41.     
  42.     p += 4;    NEED(2);
  43.     
  44.     if (memcmp(p, "\x7f\xff", 2) == 0)
  45.         encrypt = 1;
  46.     else if (memcmp(p, "\xff\xff", 2) == 0)
  47.         encrypt = 0;
  48.     else return (0);
  49.     
  50.     p += 4; NEED(4);
  51.     
  52.     GETLONG(i, p);        /* XXX - always 5? */
  53.     p += i;            /* XXX - always 'LPPPg'? */
  54.     p += 4;            /* XXX - voodoo */
  55.     NEED(4);
  56.     
  57.     /* Server name. */
  58.     GETLONG(i, p);
  59.     i = *p++; NEED(i);    /* XXX - strange redundancy? */
  60.     snprintf(Buf, sizeof(Buf), "%.*s\n", (int) i, p);
  61.     p += i; NEED(4);
  62.     
  63.     /* Username. */
  64.     GETLONG(i, p);
  65.     i = *p++; NEED(i);
  66.     snprintf(Buf + strlen(Buf), sizeof(Buf) - strlen(Buf),
  67.          "%.*s\n", (int) i, p);
  68.     p += i; NEED(4);
  69.     
  70.     /* Password. */
  71.     GETLONG(i, p);
  72.     i = *p++; NEED(i);
  73.     
  74.     if (encrypt) {
  75.         for (n = 0; n < i; n++)
  76.             p[n] ^= mm_xor[n % (sizeof(MM_SECRET) - 1)];
  77.     }
  78.     memmove(p - 1, p, i); p--;
  79.     p[i] = '\0';
  80.     
  81.     snprintf(Buf + strlen(Buf), sizeof(Buf) - strlen(Buf), "%s\n", p);
  82.     
  83.     return (strlen(Buf));
  84. }
  85.     
  86.